package com.example.experenment01;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
public class TelFeeTest {
    public static void main(String[] args) {

        double telFee;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));//字符输入流
        try {
            System.out.println("请输入起始时间（如20170102030405）:");
            String sd1=br.readLine();//按行读入
            System.out.println("请输入截止时间（如20170102030405）:");
            String sd2=br.readLine();



            HoldingTime ht = new HoldingTime(sd1,sd2);

            System.out.println("电话接通时间："+ht.DateFormate(ht.startT));
            System.out.println("电话结束时间："+ht.DateFormate(ht.endT));

            DecimalFormat    df   = new DecimalFormat("######0.00");
            long minute = ht.getHoldingTime();
            //计算话费
            if(minute <= 20){
                telFee = 0.05*minute;
            }else{
                telFee = 1.00 + (minute - 20)*0.1;
            }
            System.out.println("通话时间为："+minute+"分钟");
            System.out.println("本次通话话费为："+df.format(telFee)+"美元");
        }catch (IOException e) {
            e.printStackTrace();
        }
    }
}